#include "knl_baseConfig.h"


namespace knl
{
	knl::knl_baseConfig::knl_baseConfig()
	{

	}

	knl::knl_baseConfig::~knl_baseConfig()
	{

	}

	knl_configValue& knl_baseConfig::operator[]( const knlString _key )
	{
		KNL_CONFIG_MAP::iterator _iter = m_value.find(_key);

		if (_iter != m_value.end())
			return knl_configValue(_iter->second);

		return knl_configValue("0");
	}

	knl_configValue& knl_baseConfig::operator[]( std::string _key )
	{
		return (*this)[_key.c_str()];
	}


	//////////////////////////////////////////////////////////////////////////
	// value config
	knl_configValue::knl_configValue( const std::string& _value )
	{
		_cfvalue = _value;
	}

	knl_configValue::~knl_configValue()
	{

	}

	knlInt knl_configValue::asInt()
	{
		return boost::lexical_cast<int>(_cfvalue);
	}

	float knl_configValue::asFloat()
	{
		return boost::lexical_cast<float>(_cfvalue);
	}

	double knl_configValue::asDouble()
	{
		return boost::lexical_cast<double>(_cfvalue);
	}

	std::string knl_configValue::asString()
	{
		return _cfvalue;
	}

	knlString knl_configValue::asKnlString()
	{
		return (knlString)_cfvalue.c_str();
	}

	knlDword knl_configValue::asDword()
	{
		return boost::lexical_cast<knlDword>(_cfvalue);
	}

	knlWord knl_configValue::asWord()
	{
		return boost::lexical_cast<knlWord>(_cfvalue);
	}

	void knl_configValue::splitString( const std::string _value,knlString _token,knlSplitVEC& _vec )
	{
		boost::split(_vec,_value,boost::is_any_of(_token), boost::algorithm::token_compress_on);
	}

}